package com.shixun.dds_11.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shixun.dds_11.entity.DdsGoods;
import com.shixun.dds_11.entity.DdsNote;
import com.shixun.dds_11.mapper.DdsGoodsMapper;
import com.shixun.dds_11.mapper.DdsNoteMapper;
import com.shixun.dds_11.service.IDdsNoteService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author YSP
 * @since 2024-07-05
 */
@Service
public class DdsNoteServiceImpl extends ServiceImpl<DdsNoteMapper, DdsNote> implements IDdsNoteService {

    @Autowired
    DdsNoteMapper ddsNoteMapper;
    @Autowired
    DdsGoodsMapper ddsGoodsMapper;


    @Override
    public List info(Integer userId) {

        QueryWrapper<DdsNote> queryWrapper=new QueryWrapper<DdsNote>()
                .eq("user_id",userId)
                .orderByDesc("id");
        Page<DdsNote> page=page(new Page<>(1,5),queryWrapper);
        List<DdsGoods> list=new ArrayList<>();
        for (DdsNote record : page.getRecords()) {
            list.add(ddsGoodsMapper.selectById(record.getGoodsId()));
        }
        return list;
    }
}

